package com.example.android.ui.mine;


import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.android.R;
import com.example.android.ui.base.BaseActivity;
import com.example.android.ui.login.LoginActivity;
import com.example.android.ui.personal.PersonalActivity;

public class SetActivity extends BaseActivity implements View.OnClickListener {
    private Button quit;
    private ImageView back;
    private TextView personal;

    @Override
    protected void initViews() {
        back = find(R.id.set_back);
        quit = find(R.id.set_button_quit);
        personal = find(R.id.setPersonalMessage);
        //点击事件
        back.setOnClickListener(this);
        quit.setOnClickListener(this);
        personal.setOnClickListener(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_set;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.set_back:
                finish();
                break;
            case R.id.set_button_quit:
                Intent intent = new Intent(SetActivity.this, LoginActivity.class);
                SharedPreferences sharedPreferences = getSharedPreferences("HBUserLogin", MODE_PRIVATE);
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putBoolean("isLogin", false);
                editor.commit();
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();
            case R.id.setPersonalMessage:
                Intent intent1 = new Intent(SetActivity.this, PersonalActivity.class);
                startActivity(intent1);
            default:
                break;
        }
    }
}